package milktea.servlet.cart;

import milktea.entity.CART;
import milktea.entity.ORDER;
import milktea.entity.USER;
import milktea.service.CARTService;
import milktea.service.ORDERService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/all_order")
public class AllOrder extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        HttpSession session = req.getSession();

        String isLogin = (String) session.getAttribute("isLogin");

        USER user = (USER) session.getAttribute("name");

        String uid = (String) user.getUSER_ID();

//        ArrayList<CART> list = CARTService.GoodsByID(uid);
        ArrayList<ORDER> list = ORDERService.OrdersByID(uid);

        req.setAttribute("orderslist", list);

//        req.getRequestDispatcher("goods.jsp").forward(req, resp);
        req.getRequestDispatcher("orderDetail.jsp").forward(req, resp);

    }
}
